<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>微博时间 | 新浪微博开发笔记</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.1.0">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
    

        
    
    
    <link rel="next" href="../ending/regex.html" />
    
    
    <link rel="prev" href="../ending/index.html" />
    

        
    </head>
    <body>
        
        
    <div class="book" data-level="0.13.1" data-basepath=".." data-revision="Wed Oct 14 2015 07:05:46 GMT+0800 (CST)">
    

<div class="book-summary">
    <div class="book-search">
        <input type="text" placeholder="Type to search" class="form-control" />
    </div>
    <ul class="summary">
        
        
        
        

        

        
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                        <i class="fa fa-check"></i>
                        
                        新浪微博笔记
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.1" data-path="project init/prepare project.html">
            
                
                    <a href="../project init/prepare project.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.1.</b>
                        
                        准备工作
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.1.1" data-path="project init/project deploy.html">
            
                
                    <a href="../project init/project deploy.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.1.1.</b>
                        
                        项目部署
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.1.2" data-path="project init/project settings.html">
            
                
                    <a href="../project init/project settings.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.1.2.</b>
                        
                        项目设置
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.1.3" data-path="project init/confirm architecture.html">
            
                
                    <a href="../project init/confirm architecture.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.1.3.</b>
                        
                        架构确定
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.1.4" data-path="project init/mvvm.html">
            
                
                    <a href="../project init/mvvm.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.1.4.</b>
                        
                        MVVM
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.2" data-path="create project/readme.html">
            
                
                    <a href="../create project/readme.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.2.</b>
                        
                        项目搭建
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.2.1" data-path="create project/create files.html">
            
                
                    <a href="../create project/create files.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.2.1.</b>
                        
                        创建文件
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.2.2" data-path="create project/add child controllers.html">
            
                
                    <a href="../create project/add child controllers.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.2.2.</b>
                        
                        添加子控制器
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.2.3" data-path="create project/custom main tabbar.html">
            
                
                    <a href="../create project/custom main tabbar.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.2.3.</b>
                        
                        自定义 TabBar
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.2.4" data-path="create project/summary.html">
            
                
                    <a href="../create project/summary.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.2.4.</b>
                        
                        阶段性小结
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.3" data-path="visitor/readme.html">
            
                
                    <a href="../visitor/readme.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.3.</b>
                        
                        访客视图
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.3.1" data-path="visitor/base table view controller.html">
            
                
                    <a href="../visitor/base table view controller.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.3.1.</b>
                        
                        表格视图控制器基类
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.3.2" data-path="visitor/visitor login view.html">
            
                
                    <a href="../visitor/visitor login view.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.3.2.</b>
                        
                        用户登录视图
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.3.3" data-path="visitor/setup login info.html">
            
                
                    <a href="../visitor/setup login info.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.3.3.</b>
                        
                        设置未登录信息
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.3.4" data-path="visitor/home animation.html">
            
                
                    <a href="../visitor/home animation.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.3.4.</b>
                        
                        首页动画
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.3.5" data-path="visitor/login buttons delegate.html">
            
                
                    <a href="../visitor/login buttons delegate.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.3.5.</b>
                        
                        登录&amp;注册代理回调
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.3.6" data-path="visitor/appearance.html">
            
                
                    <a href="../visitor/appearance.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.3.6.</b>
                        
                        导航栏全局外观
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.4" data-path="frameworks/readme.html">
            
                
                    <a href="../frameworks/readme.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.4.</b>
                        
                        第三方框架
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.4.1" data-path="frameworks/afnetworking.html">
            
                
                    <a href="../frameworks/afnetworking.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.4.1.</b>
                        
                        AFNetworking
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.4.2" data-path="frameworks/svprogresshud sdwebimage.html">
            
                
                    <a href="../frameworks/svprogresshud sdwebimage.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.4.2.</b>
                        
                        SVProgressHUD 和 SDWebImage
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.4.3" data-path="frameworks/snapkit.html">
            
                
                    <a href="../frameworks/snapkit.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.4.3.</b>
                        
                        SnapKit
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.5" data-path="oauth/readme.html">
            
                
                    <a href="../oauth/readme.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.5.</b>
                        
                        OAuth
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.5.1" data-path="oauth/register app.html">
            
                
                    <a href="../oauth/register app.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.5.1.</b>
                        
                        注册应用程序
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.5.2" data-path="oauth/load oauth page.html">
            
                
                    <a href="../oauth/load oauth page.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.5.2.</b>
                        
                        加载授权页面
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.6" data-path="access token/readme.html">
            
                
                    <a href="../access token/readme.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.6.</b>
                        
                        Access Token
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.6.1" data-path="access token/load access token.html">
            
                
                    <a href="../access token/load access token.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.6.1.</b>
                        
                        加载 AccessToken
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.6.2" data-path="access token/user account.html">
            
                
                    <a href="../access token/user account.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.6.2.</b>
                        
                        用户账户模型
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.6.3" data-path="access token/expires date.html">
            
                
                    <a href="../access token/expires date.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.6.3.</b>
                        
                        过期日期
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.6.4" data-path="access token/load user info.html">
            
                
                    <a href="../access token/load user info.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.6.4.</b>
                        
                        加载用户信息
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.6.5" data-path="access token/archive user account.html">
            
                
                    <a href="../access token/archive user account.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.6.5.</b>
                        
                        归档 &amp; 解档
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.6.6" data-path="access token/view model.html">
            
                
                    <a href="../access token/view model.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.6.6.</b>
                        
                        视图模型
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.6.7" data-path="access token/error enum.html">
            
                
                    <a href="../access token/error enum.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.6.7.</b>
                        
                        自定义错误枚举
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.7" data-path="newfeature/index.html">
            
                
                    <a href="../newfeature/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.7.</b>
                        
                        新特性和欢迎界面
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.7.1" data-path="newfeature/newfeature.html">
            
                
                    <a href="../newfeature/newfeature.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.7.1.</b>
                        
                        新特性
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.7.2" data-path="newfeature/welcome.html">
            
                
                    <a href="../newfeature/welcome.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.7.2.</b>
                        
                        欢迎界面
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.7.3" data-path="newfeature/switch vc.html">
            
                
                    <a href="../newfeature/switch vc.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.7.3.</b>
                        
                        切换界面
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.8" data-path="homepage/index.html">
            
                
                    <a href="../homepage/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.8.</b>
                        
                        首页布局
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.8.1" data-path="homepage/status model.html">
            
                
                    <a href="../homepage/status model.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.8.1.</b>
                        
                        微博数据模型
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.8.2" data-path="homepage/tableview show data.html">
            
                
                    <a href="../homepage/tableview show data.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.8.2.</b>
                        
                        显示表格数据
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.8.3" data-path="homepage/user model.html">
            
                
                    <a href="../homepage/user model.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.8.3.</b>
                        
                        用户模型
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.8.4" data-path="homepage/status view model.html">
            
                
                    <a href="../homepage/status view model.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.8.4.</b>
                        
                        微博视图模型
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.8.5" data-path="homepage/custom cell.html">
            
                
                    <a href="../homepage/custom cell.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.8.5.</b>
                        
                        自定义 Cell
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.8.6" data-path="homepage/prepare for pictureview.html">
            
                
                    <a href="../homepage/prepare for pictureview.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.8.6.</b>
                        
                        配图视图准备
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.8.7" data-path="homepage/picture view.html">
            
                
                    <a href="../homepage/picture view.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.8.7.</b>
                        
                        配图视图
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.8.8" data-path="homepage/retweeted_status.html">
            
                
                    <a href="../homepage/retweeted_status.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.8.8.</b>
                        
                        转发微博
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.8.9" data-path="homepage/single picture.html">
            
                
                    <a href="../homepage/single picture.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.8.9.</b>
                        
                        单张图片比例
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.9" data-path="refresh/index.html">
            
                
                    <a href="../refresh/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.9.</b>
                        
                        刷新
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.9.1" data-path="refresh/pullup view.html">
            
                
                    <a href="../refresh/pullup view.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.9.1.</b>
                        
                        上拉刷新控件
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.9.2" data-path="refresh/refresh data.html">
            
                
                    <a href="../refresh/refresh data.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.9.2.</b>
                        
                        刷新数据
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.9.3" data-path="refresh/pulldown tips.html">
            
                
                    <a href="../refresh/pulldown tips.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.9.3.</b>
                        
                        下拉刷新提示
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.10" data-path="compose/index.html">
            
                
                    <a href="../compose/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.10.</b>
                        
                        发布微博
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.10.1" data-path="compose/setup ui.html">
            
                
                    <a href="../compose/setup ui.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.10.1.</b>
                        
                        搭建界面
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.10.2" data-path="compose/select picture.html">
            
                
                    <a href="../compose/select picture.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.10.2.</b>
                        
                        选择照片
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.10.3" data-path="compose/post status.html">
            
                
                    <a href="../compose/post status.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.10.3.</b>
                        
                        发布微博
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.11" data-path="emoticon/index.html">
            
                
                    <a href="../emoticon/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.11.</b>
                        
                        表情键盘
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.11.1" data-path="emoticon/prepare ui.html">
            
                
                    <a href="../emoticon/prepare ui.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.11.1.</b>
                        
                        准备界面
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.11.2" data-path="emoticon/load bundle data.html">
            
                
                    <a href="../emoticon/load bundle data.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.11.2.</b>
                        
                        加载模型数据
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.11.3" data-path="emoticon/show emoticon.html">
            
                
                    <a href="../emoticon/show emoticon.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.11.3.</b>
                        
                        显示表情符号
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.11.4" data-path="emoticon/upgrade model.html">
            
                
                    <a href="../emoticon/upgrade model.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.11.4.</b>
                        
                        提升数据模型
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.11.5" data-path="emoticon/selected emoticon.html">
            
                
                    <a href="../emoticon/selected emoticon.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.11.5.</b>
                        
                        选中表情事件
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.11.6" data-path="emoticon/attribute text.html">
            
                
                    <a href="../emoticon/attribute text.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.11.6.</b>
                        
                        属性文本
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.11.7" data-path="emoticon/merge_emoticon.html">
            
                
                    <a href="../emoticon/merge_emoticon.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.11.7.</b>
                        
                        整合到新浪微博
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.11.8" data-path="emoticon/favorite emoticon.html">
            
                
                    <a href="../emoticon/favorite emoticon.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.11.8.</b>
                        
                        内存表情排序
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.12" data-path="sqlite/index.html">
            
                
                    <a href="../sqlite/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.12.</b>
                        
                        数据缓存
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.12.1" data-path="sqlite/data model.html">
            
                
                    <a href="../sqlite/data model.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.12.1.</b>
                        
                        数据模型设计
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.12.2" data-path="sqlite/statusdal.html">
            
                
                    <a href="../sqlite/statusdal.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.12.2.</b>
                        
                        数据访问层
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.12.3" data-path="sqlite/clean cache.html">
            
                
                    <a href="../sqlite/clean cache.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.12.3.</b>
                        
                        清理数据缓存
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.13" data-path="ending/index.html">
            
                
                    <a href="../ending/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.13.</b>
                        
                        微博收尾
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="0.13.1" data-path="ending/status create at.html">
            
                
                    <a href="../ending/status create at.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.13.1.</b>
                        
                        微博时间
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.13.2" data-path="ending/regex.html">
            
                
                    <a href="../ending/regex.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.13.2.</b>
                        
                        正则表达式
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.13.3" data-path="ending/emoticon string.html">
            
                
                    <a href="../ending/emoticon string.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.13.3.</b>
                        
                        表情字符串
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.13.4" data-path="ending/fflabel.html">
            
                
                    <a href="../ending/fflabel.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.13.4.</b>
                        
                        FFLabel
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.13.5" data-path="ending/textkit.html">
            
                
                    <a href="../ending/textkit.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.13.5.</b>
                        
                        TextKit
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="0.14" data-path="appendix/readme.html">
            
                
                    <a href="../appendix/readme.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.14.</b>
                        
                        附录
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="0.14.1" data-path="appendix/image assets.html">
            
                
                    <a href="../appendix/image assets.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.14.1.</b>
                        
                        图片素材
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.14.2" data-path="appendix/cocoa pod.html">
            
                
                    <a href="../appendix/cocoa pod.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.14.2.</b>
                        
                        cocoa pod
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.14.3" data-path="appendix/singleton.html">
            
                
                    <a href="../appendix/singleton.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.14.3.</b>
                        
                        单例
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.14.4" data-path="appendix/swift_vs_oc.html">
            
                
                    <a href="../appendix/swift_vs_oc.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.14.4.</b>
                        
                        为什么要学习 Swift
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="0.14.5" data-path="appendix/emoji.html">
            
                
                    <a href="../appendix/emoji.html">
                        <i class="fa fa-check"></i>
                        
                            <b>0.14.5.</b>
                        
                        emoji
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    


        
        <li class="divider"></li>
        <li>
            <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                Published with GitBook
            </a>
        </li>
        
    </ul>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header">
    <!-- Actions Left -->
    <a href="#" class="btn pull-left toggle-summary" aria-label="Table of Contents"><i class="fa fa-align-justify"></i></a>
    <a href="#" class="btn pull-left toggle-search" aria-label="Search"><i class="fa fa-search"></i></a>
    
    <div id="font-settings-wrapper" class="dropdown pull-left">
        <a href="#" class="btn toggle-dropdown" aria-label="Font Settings"><i class="fa fa-font"></i>
        </a>
        <div class="dropdown-menu font-settings">
    <div class="dropdown-caret">
        <span class="caret-outer"></span>
        <span class="caret-inner"></span>
    </div>

    <div class="buttons">
        <button type="button" id="reduce-font-size" class="button size-2">A</button>
        <button type="button" id="enlarge-font-size" class="button size-2">A</button>
    </div>

    <div class="buttons font-family-list">
        <button type="button" data-font="0" class="button">Serif</button>
        <button type="button" data-font="1" class="button">Sans</button>
    </div>

    <div class="buttons color-theme-list">
        <button type="button" id="color-theme-preview-0" class="button size-3" data-theme="0">White</button>
        <button type="button" id="color-theme-preview-1" class="button size-3" data-theme="1">Sepia</button>
        <button type="button" id="color-theme-preview-2" class="button size-3" data-theme="2">Night</button>
    </div>
</div>

    </div>

    <!-- Actions Right -->
    
    <div class="dropdown pull-right">
        <a href="#" class="btn toggle-dropdown" aria-label="Share"><i class="fa fa-share-alt"></i>
        </a>
        <div class="dropdown-menu font-settings dropdown-left">
            <div class="dropdown-caret">
                <span class="caret-outer"></span>
                <span class="caret-inner"></span>
            </div>
            <div class="buttons">
                <button type="button" data-sharing="twitter" class="button">
                    Share on Twitter
                </button>
                <button type="button" data-sharing="google-plus" class="button">
                    Share on Google
                </button>
                <button type="button" data-sharing="facebook" class="button">
                    Share on Facebook
                </button>
                <button type="button" data-sharing="weibo" class="button">
                    Share on Weibo
                </button>
                <button type="button" data-sharing="instapaper" class="button">
                    Share on Instapaper
                </button>
            </div>
        </div>
    </div>
    

    
    <a href="#" target="_blank" class="btn pull-right google-plus-sharing-link sharing-link" data-sharing="google-plus" aria-label="Google"><i class="fa fa-google-plus"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right facebook-sharing-link sharing-link" data-sharing="facebook" aria-label="Facebook"><i class="fa fa-facebook"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="twitter" aria-label="Twitter"><i class="fa fa-twitter"></i></a>
    
    
    


    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >新浪微博开发笔记</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="%E5%BE%AE%E5%8D%9A%E6%97%B6%E9%97%B4">&#x5FAE;&#x535A;&#x65F6;&#x95F4;</h1>
<h1 id="%E6%97%A5%E6%9C%9F%E5%A4%84%E7%90%86">&#x65E5;&#x671F;&#x5904;&#x7406;</h1>
<h2 id="%E6%96%B0%E6%B5%AA%E5%BE%AE%E5%8D%9A%E6%97%A5%E6%9C%9F%E6%A0%BC%E5%BC%8F">&#x65B0;&#x6D6A;&#x5FAE;&#x535A;&#x65E5;&#x671F;&#x683C;&#x5F0F;</h2>
<pre><code>Tue Sep 15 12:12:00 +0800 2015
&#x661F;&#x671F; &#x6708; &#x65E5; &#x65F6;:&#x5206;:&#x79D2; &#x65F6;&#x533A; &#x5E74;
</code></pre><blockquote>
<p>&#x8981;&#x4ECE;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x89E3;&#x6790;&#x5F97;&#x5230;&#x51C6;&#x786E;&#x7684;&#x65F6;&#x95F4;&#xFF0C;&#x5FC5;&#x987B;&#x8981;&#x6307;&#x5B9A;<code>&#x6B63;&#x786E;&#x7684;&#x683C;&#x5F0F;&#x5B57;&#x7B26;&#x4E32;</code>&#xFF0C;&#x4EE5;&#x53CA;&#x5BF9;&#x5E94;&#x7684;<code>&#x65F6;&#x533A;&#x6807;&#x793A;</code></p>
</blockquote>
<h2 id="%E6%97%A5%E6%9C%9F%E6%A0%BC%E5%BC%8F">&#x65E5;&#x671F;&#x683C;&#x5F0F;</h2>
<ul>
<li>&#x5E74;<ul>
<li><code>y</code> &#x5C06;&#x5E74;&#x4EFD; (0-9) &#x663E;&#x793A;&#x4E3A;&#x4E0D;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;</li>
<li><code>yy</code> &#x4EE5;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x4E24;&#x4F4D;&#x6570;&#x5B57;&#x683C;&#x5F0F;&#x663E;&#x793A;&#x5E74;&#x4EFD;</li>
<li><code>yyy</code> &#x4EE5;&#x56DB;&#x4F4D;&#x6570;&#x5B57;&#x683C;&#x5F0F;&#x663E;&#x793A;&#x5E74;&#x4EFD;</li>
<li><code>yyyy</code> &#x4EE5;&#x56DB;&#x4F4D;&#x6570;&#x5B57;&#x683C;&#x5F0F;&#x663E;&#x793A;&#x5E74;&#x4EFD;</li>
</ul>
</li>
<li><p>&#x6708;</p>
<ul>
<li><code>M</code> &#x5C06;&#x6708;&#x4EFD;&#x663E;&#x793A;&#x4E3A;&#x4E0D;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;&#xFF08;&#x5982;&#x4E00;&#x6708;&#x8868;&#x793A;&#x4E3A; 1&#xFF09;</li>
<li><code>MM</code> &#x5C06;&#x6708;&#x4EFD;&#x663E;&#x793A;&#x4E3A;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;&#xFF08;&#x4F8B;&#x5982; 01/12/01&#xFF09;</li>
<li><code>MMM</code> &#x5C06;&#x6708;&#x4EFD;&#x663E;&#x793A;&#x4E3A;&#x7F29;&#x5199;&#x5F62;&#x5F0F;&#xFF08;&#x4F8B;&#x5982; Jan&#xFF09;</li>
<li><code>MMMM</code> &#x5C06;&#x6708;&#x4EFD;&#x663E;&#x793A;&#x4E3A;&#x5B8C;&#x6574;&#x6708;&#x4EFD;&#x540D;&#xFF08;&#x4F8B;&#x5982; January&#xFF09;<ul>
<li>&#x4E00;&#x6708; Jan January</li>
<li>&#x4E8C;&#x6708; Feb February</li>
<li>&#x4E09;&#x6708; Mar March</li>
<li>&#x56DB;&#x6708; Apr April</li>
<li>&#x4E94;&#x6708; May May</li>
<li>&#x516D;&#x6708; Jun June</li>
<li>&#x4E03;&#x6708; Jul July</li>
<li>&#x516B;&#x6708; Aug August</li>
<li>&#x4E5D;&#x6708; Sep September</li>
<li>&#x5341;&#x6708; Oct October</li>
<li>&#x5341;&#x4E00;&#x6708; Nov November</li>
<li>&#x5341;&#x4E8C;&#x6708; Dec December</li>
</ul>
</li>
</ul>
</li>
<li><p>&#x65E5;</p>
<ul>
<li><code>d</code> &#x5C06;&#x65E5;&#x663E;&#x793A;&#x4E3A;&#x4E0D;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;&#xFF08;&#x5982; 1&#xFF09;</li>
<li><code>dd</code> &#x5C06;&#x65E5;&#x663E;&#x793A;&#x4E3A;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;&#xFF08;&#x5982; 01&#xFF09;</li>
</ul>
</li>
<li>&#x661F;&#x671F;<ul>
<li><code>EEE</code> &#x5C06;&#x65E5;&#x663E;&#x793A;&#x4E3A;&#x7F29;&#x5199;&#x5F62;&#x5F0F;&#xFF08;&#x4F8B;&#x5982; Sun&#xFF09;</li>
<li><code>EEEE</code> &#x5C06;&#x65E5;&#x663E;&#x793A;&#x4E3A;&#x5168;&#x540D;&#xFF08;&#x4F8B;&#x5982; Sunday&#xFF09;<ul>
<li>&#x661F;&#x671F;&#x4E00; Mon Monday</li>
<li>&#x661F;&#x671F;&#x4E8C; Tue Tuesday</li>
<li>&#x661F;&#x671F;&#x4E09; Wed Wednesday</li>
<li>&#x661F;&#x671F;&#x56DB; Thu Thursday</li>
<li>&#x661F;&#x671F;&#x4E94; Fri Friday</li>
<li>&#x661F;&#x671F;&#x516D; Sat Saturday</li>
<li>&#x661F;&#x671F;&#x5929; Sun Sunday</li>
</ul>
</li>
</ul>
</li>
<li>&#x5C0F;&#x65F6;<ul>
<li><code>h</code> &#x4F7F;&#x7528; 12 &#x5C0F;&#x65F6;&#x5236;&#x5C06;&#x5C0F;&#x65F6;&#x663E;&#x793A;&#x4E3A;&#x4E0D;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;&#xFF08;&#x4F8B;&#x5982; 1:15:15 PM&#xFF09;</li>
<li><code>hh</code> &#x4F7F;&#x7528; 12 &#x5C0F;&#x65F6;&#x5236;&#x5C06;&#x5C0F;&#x65F6;&#x663E;&#x793A;&#x4E3A;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;&#xFF08;&#x4F8B;&#x5982; 01:15:15 PM&#xFF09;</li>
<li><code>H</code> &#x4F7F;&#x7528; 24 &#x5C0F;&#x65F6;&#x5236;&#x5C06;&#x5C0F;&#x65F6;&#x663E;&#x793A;&#x4E3A;&#x4E0D;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;&#xFF08;&#x4F8B;&#x5982; 1:15:15&#xFF09;</li>
<li><code>HH</code> &#x4F7F;&#x7528; 24 &#x5C0F;&#x65F6;&#x5236;&#x5C06;&#x5C0F;&#x65F6;&#x663E;&#x793A;&#x4E3A;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;&#xFF08;&#x4F8B;&#x5982; 01:15:15&#xFF09;</li>
</ul>
</li>
<li>&#x5206;&#x949F;<ul>
<li><code>m</code> &#x5C06;&#x5206;&#x949F;&#x663E;&#x793A;&#x4E3A;&#x4E0D;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;&#xFF08;&#x4F8B;&#x5982; 12:1:15&#xFF09;</li>
<li><code>mm</code> &#x5C06;&#x5206;&#x949F;&#x663E;&#x793A;&#x4E3A;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;&#xFF08;&#x4F8B;&#x5982; 12:01:15&#xFF09;</li>
</ul>
</li>
<li>&#x79D2;<ul>
<li><code>s</code> &#x5C06;&#x79D2;&#x663E;&#x793A;&#x4E3A;&#x4E0D;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;&#xFF08;&#x4F8B;&#x5982; 12:15:5&#xFF09;</li>
<li><code>ss</code> &#x5C06;&#x79D2;&#x663E;&#x793A;&#x4E3A;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x6570;&#x5B57;&#xFF08;&#x4F8B;&#x5982; 12:15:05&#xFF09;</li>
<li><code>f</code> &#x663E;&#x793A;&#x79D2;&#x7684;&#x5C0F;&#x6570;&#x90E8;&#x5206;</li>
<li><code>ff</code> &#x5C06;&#x7CBE;&#x786E;&#x663E;&#x793A;&#x5230;&#x767E;&#x5206;&#x4E4B;&#x4E00;&#x79D2;</li>
<li><code>ffff</code> &#x5C06;&#x7CBE;&#x786E;&#x663E;&#x793A;&#x5230;&#x4E07;&#x5206;&#x4E4B;&#x4E00;&#x79D2;</li>
<li>&#x7528;&#x6237;&#x5B9A;&#x4E49;&#x683C;&#x5F0F;&#x4E2D;&#x6700;&#x591A;&#x53EF;&#x4F7F;&#x7528;&#x4E03;&#x4E2A; f &#x7B26;&#x53F7;</li>
</ul>
</li>
<li>&#x4E0A;&#x5348;&amp;&#x4E0B;&#x5348;<ul>
<li><code>t</code> &#x4F7F;&#x7528; 12 &#x5C0F;&#x65F6;&#x5236;<ul>
<li>&#x4E2D;&#x5348;&#x4E4B;&#x524D;&#x4EFB;&#x4E00;&#x5C0F;&#x65F6;&#x663E;&#x793A;&#x5927;&#x5199;&#x7684; A</li>
<li>&#x4E2D;&#x5348;&#x5230; 11:59 PM &#x4E4B;&#x95F4;&#x7684;&#x4EFB;&#x4E00;&#x5C0F;&#x65F6;&#x663E;&#x793A;&#x5927;&#x5199;&#x7684; P</li>
</ul>
</li>
<li><code>tt</code> &#x5BF9;&#x4E8E;&#x4F7F;&#x7528; 12 &#x5C0F;&#x65F6;&#x5236;&#x7684;&#x533A;&#x57DF;&#x8BBE;&#x7F6E;<ul>
<li>&#x4E2D;&#x5348;&#x4E4B;&#x524D;&#x4EFB;&#x4E00;&#x5C0F;&#x65F6;&#x663E;&#x793A;&#x5927;&#x5199;&#x7684; AM</li>
<li>&#x4E2D;&#x5348;&#x5230; 11:59 PM &#x4E4B;&#x95F4;&#x7684;&#x4EFB;&#x4E00;&#x5C0F;&#x65F6;&#x663E;&#x793A;&#x5927;&#x5199;&#x7684; PM</li>
</ul>
</li>
<li>&#x5BF9;&#x4E8E;&#x4F7F;&#x7528; 24 &#x5C0F;&#x65F6;&#x5236;&#x7684;&#x533A;&#x57DF;&#x8BBE;&#x7F6E;&#xFF0C;&#x4E0D;&#x663E;&#x793A;&#x4EFB;&#x4F55;&#x5B57;&#x7B26;</li>
</ul>
</li>
<li>&#x65F6;&#x533A;<ul>
<li><code>z</code> &#x663E;&#x793A;&#x4E0D;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x65F6;&#x533A;&#x504F;&#x79FB;&#x91CF;</li>
<li><code>zz</code> &#x663E;&#x793A;&#x5E26;&#x524D;&#x5BFC;&#x96F6;&#x7684;&#x65F6;&#x533A;&#x504F;&#x79FB;&#x91CF;&#xFF08;&#x4F8B;&#x5982; -08&#xFF09;</li>
<li><code>zzz</code> &#x663E;&#x793A;&#x5B8C;&#x6574;&#x7684;&#x65F6;&#x533A;&#x504F;&#x79FB;&#x91CF;&#xFF08;&#x4F8B;&#x5982; -0800&#xFF09;</li>
</ul>
</li>
<li>&#x7EAA;&#x5143;<ul>
<li><code>gg</code> &#x663E;&#x793A;&#x65F6;&#x4EE3;/&#x7EAA;&#x5143;&#x5B57;&#x7B26;&#x4E32;&#xFF08;&#x4F8B;&#x5982; A.D.&#xFF09;</li>
</ul>
</li>
</ul>
<h2 id="%E6%97%A5%E6%9C%9F%E8%BD%AC%E6%8D%A2%E6%B5%8B%E8%AF%95%E4%BB%A3%E7%A0%81">&#x65E5;&#x671F;&#x8F6C;&#x6362;&#x6D4B;&#x8BD5;&#x4EE3;&#x7801;</h2>
<pre><code class="lang-swift"><span class="hljs-keyword">var</span> create_date = <span class="hljs-string">&quot;Tue Sep 15 12:12:00 +0800 2015&quot;</span>
<span class="hljs-keyword">let</span> df = <span class="hljs-type">NSDateFormatter</span>()
df.locale = <span class="hljs-type">NSLocale</span>(localeIdentifier: <span class="hljs-string">&quot;en&quot;</span>)
df.dateFormat = <span class="hljs-string">&quot;EEE MMM dd HH:mm:ss zzz yyyy&quot;</span>
<span class="hljs-keyword">let</span> date = df.dateFromString(create_date)
</code></pre>
<h2 id="%E6%97%A5%E6%9C%9F%E9%9C%80%E6%B1%82">&#x65E5;&#x671F;&#x9700;&#x6C42;</h2>
<ul>
<li>&#x521A;&#x521A;(&#x4E00;&#x5206;&#x949F;&#x5185;)</li>
<li>X&#x5206;&#x949F;&#x524D;(&#x4E00;&#x5C0F;&#x65F6;&#x5185;)</li>
<li>X&#x5C0F;&#x65F6;&#x524D;(&#x5F53;&#x5929;)</li>
<li>&#x6628;&#x5929; HH:mm(&#x6628;&#x5929;)</li>
<li>MM-dd HH:mm(&#x4E00;&#x5E74;&#x5185;)</li>
<li>yyyy-MM-dd HH:mm(&#x66F4;&#x65E9;&#x671F;)</li>
</ul>
<h3 id="%E6%97%A5%E6%9C%9F%E5%88%86%E7%B1%BB">&#x65E5;&#x671F;&#x5206;&#x7C7B;</h3>
<ul>
<li>&#x5EFA;&#x7ACB; <code>Date+Extension.swift</code></li>
<li>&#x62BD;&#x53D6;&#x7C7B;&#x51FD;&#x6570;&#x521B;&#x5EFA;&#x65E5;&#x671F;</li>
</ul>
<pre><code class="lang-swift"><span class="hljs-comment">/// &#x4F7F;&#x7528;&#x65B0;&#x6D6A;&#x65E5;&#x671F;&#x5B57;&#x7B26;&#x4E32;&#x521B;&#x5EFA;&#x65E5;&#x671F;</span>
<span class="hljs-keyword">class</span> <span class="hljs-func"><span class="hljs-keyword">func</span> <span class="hljs-title">sinaDate</span><span class="hljs-params">(str: String)</span> -&gt; <span class="hljs-title">NSDate</span>? </span>{
    <span class="hljs-keyword">let</span> df = <span class="hljs-type">NSDateFormatter</span>()
    df.locale = <span class="hljs-type">NSLocale</span>(localeIdentifier: <span class="hljs-string">&quot;en&quot;</span>)
    df.dateFormat = <span class="hljs-string">&quot;EEE MMM dd HH:mm:ss zzz yyyy&quot;</span>

    <span class="hljs-keyword">return</span> df.dateFromString(str)
}
</code></pre>
<ul>
<li><p>&#x7531;&#x4E8E;&#x5FAE;&#x535A;&#x663E;&#x793A;&#x65E5;&#x671F;&#x65F6;&#x968F;&#x65F6;&#x66F4;&#x65B0;&#x7684;&#xFF0C;&#x56E0;&#x6B64;&#x5EFA;&#x7ACB;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x5355;&#x72EC;&#x5904;&#x7406;&#x65E5;&#x671F;&#x63CF;&#x8FF0;</p>
</li>
<li><p>&#x51C6;&#x5907;&#x51FD;&#x6570;&#x5982;&#x4E0B;&#xFF1A;</p>
</li>
</ul>
<pre><code class="lang-swift"><span class="hljs-comment">/// &#x8FD4;&#x56DE;&#x65E5;&#x671F;&#x63CF;&#x8FF0;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="hljs-comment">///</span>
<span class="hljs-comment">/// &#x683C;&#x5F0F;&#x5982;&#x4E0B;</span>
<span class="hljs-comment">///     -   &#x521A;&#x521A;(&#x4E00;&#x5206;&#x949F;&#x5185;)</span>
<span class="hljs-comment">///     -   X&#x5206;&#x949F;&#x524D;(&#x4E00;&#x5C0F;&#x65F6;&#x5185;)</span>
<span class="hljs-comment">///     -   X&#x5C0F;&#x65F6;&#x524D;(&#x5F53;&#x5929;)</span>
<span class="hljs-comment">///     -   &#x6628;&#x5929; HH:mm(&#x6628;&#x5929;)</span>
<span class="hljs-comment">///     -   MM-dd HH:mm(&#x4E00;&#x5E74;&#x5185;)</span>
<span class="hljs-comment">///     -   yyyy-MM-dd HH:mm(&#x66F4;&#x65E9;&#x671F;)</span>
<span class="hljs-keyword">var</span> dateDescription: <span class="hljs-type">String</span> {
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;&quot;</span>
}
</code></pre>
<blockquote>
<p>&#x5728; iOS &#x4E2D;&#x5904;&#x7406;&#x65E5;&#x671F;&#x7684;&#x8BE6;&#x7EC6;&#x4FE1;&#x606F;&#x9700;&#x8981;&#x501F;&#x52A9;&#x5230; <code>NSCalendar</code> &#x7C7B;&#xFF0C;<code>NSCalendar</code> &#x63D0;&#x4F9B;&#x4E86;&#x975E;&#x5E38;&#x4E30;&#x5BCC;&#x7684;&#x65E5;&#x671F;&#x64CD;&#x4F5C;&#x51FD;&#x6570;</p>
</blockquote>
<ul>
<li>&#x65E5;&#x671F;&#x5206;&#x6BB5;&#x5224;&#x65AD;</li>
</ul>
<pre><code class="lang-swift"><span class="hljs-comment">/// &#x65E5;&#x671F;&#x63CF;&#x8FF0;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="hljs-keyword">var</span> dateDescription: <span class="hljs-type">String</span> {

    <span class="hljs-comment">// 1. &#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65E5;&#x5386;</span>
    <span class="hljs-keyword">let</span> calendar = <span class="hljs-type">NSCalendar</span>.currentCalendar()

    <span class="hljs-comment">// 2. &#x5224;&#x65AD;&#x5F53;&#x524D;&#x65E5;&#x671F;</span>
    <span class="hljs-keyword">if</span> calendar.isDateInToday(<span class="hljs-keyword">self</span>) {
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;&#x4ECA;&#x5929;&quot;</span>
    }

    <span class="hljs-comment">// 3. &#x5176;&#x4ED6;&#x65E5;&#x671F;</span>
    <span class="hljs-keyword">if</span> calendar.isDateInYesterday(<span class="hljs-keyword">self</span>) {
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;&#x6628;&#x5929;&quot;</span>
    }

    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;&#x5176;&#x4ED6;&quot;</span>
}
</code></pre>
<ul>
<li>&#x6D4B;&#x8BD5;&#x6570;&#x636E;</li>
</ul>
<pre><code class="lang-swift"><span class="hljs-built_in">print</span>(<span class="hljs-type">NSDate</span>.sinaDate(<span class="hljs-string">&quot;Tue Sep 15 12:12:00 +0800 2015&quot;</span>)?.dateDescription)
<span class="hljs-built_in">print</span>(<span class="hljs-type">NSDate</span>.sinaDate(<span class="hljs-string">&quot;Tue Sep 14 12:12:00 +0800 2015&quot;</span>)?.dateDescription)
<span class="hljs-built_in">print</span>(<span class="hljs-type">NSDate</span>.sinaDate(<span class="hljs-string">&quot;Tue Sep 12 12:12:00 +0800 2015&quot;</span>)?.dateDescription)
<span class="hljs-built_in">print</span>(<span class="hljs-type">NSDate</span>.sinaDate(<span class="hljs-string">&quot;Tue Sep 15 12:12:00 +0800 2014&quot;</span>)?.dateDescription)
<span class="hljs-built_in">print</span>(<span class="hljs-type">NSDate</span>.sinaDate(<span class="hljs-string">&quot;Tue Sep 14 12:12:00 +0800 2014&quot;</span>)?.dateDescription)
</code></pre>
<ul>
<li>&#x65E5;&#x5386;&#x51FD;&#x6570;</li>
</ul>
<pre><code class="lang-swift">canlendar.components(.<span class="hljs-type">Year</span>, fromDate: <span class="hljs-keyword">self</span>)
</code></pre>
<ul>
<li>&#x6BD4;&#x8F83;&#x4E24;&#x4E2A;&#x65E5;&#x671F;</li>
</ul>
<pre><code class="lang-swift"><span class="hljs-keyword">let</span> coms = calendar.components(.<span class="hljs-type">Year</span>, fromDate: <span class="hljs-keyword">self</span>, toDate: <span class="hljs-type">NSDate</span>(), options: [])

<span class="hljs-built_in">print</span>(coms.year)
</code></pre>
<ul>
<li>&#x8BA1;&#x7B97;&#x975E;&#x4ECA;&#x5929;&#x7684;&#x65E5;&#x671F;&#x4FE1;&#x606F;</li>
</ul>
<pre><code class="lang-swift"><span class="hljs-keyword">var</span> fmt = <span class="hljs-string">&quot; HH:mm&quot;</span>
<span class="hljs-keyword">if</span> calendar.isDateInYesterday(<span class="hljs-keyword">self</span>) {
    fmt = <span class="hljs-string">&quot;&#x6628;&#x5929;&quot;</span> + fmt
} <span class="hljs-keyword">else</span> {
    fmt = <span class="hljs-string">&quot;MM-dd&quot;</span> + fmt

    <span class="hljs-comment">// &#x66F4;&#x65E9;&#x671F;</span>
    <span class="hljs-keyword">if</span> (calendar.components(.<span class="hljs-type">Year</span>, fromDate: <span class="hljs-keyword">self</span>, toDate: <span class="hljs-type">NSDate</span>(), options: [])).year &gt; <span class="hljs-number">0</span> {
        fmt = <span class="hljs-string">&quot;yyyy-&quot;</span> + fmt
    }
}

<span class="hljs-keyword">let</span> df = <span class="hljs-type">NSDateFormatter</span>()
df.locale = <span class="hljs-type">NSLocale</span>(localeIdentifier: <span class="hljs-string">&quot;en&quot;</span>)
df.dateFormat = fmt

<span class="hljs-keyword">return</span> df.stringFromDate(<span class="hljs-keyword">self</span>)
</code></pre>
<ul>
<li>&#x8BA1;&#x7B97;&#x4ECA;&#x5929;&#x7684;&#x65E5;&#x671F;&#x4FE1;&#x606F;</li>
</ul>
<pre><code class="lang-swift"><span class="hljs-comment">// 1. &#x4ECA;&#x5929;</span>
<span class="hljs-keyword">if</span> calendar.isDateInToday(<span class="hljs-keyword">self</span>) {
    <span class="hljs-keyword">let</span> delta = <span class="hljs-type">Int</span>(<span class="hljs-type">NSDate</span>().timeIntervalSinceDate(<span class="hljs-keyword">self</span>))

    <span class="hljs-keyword">if</span> delta &lt; <span class="hljs-number">60</span> {
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;&#x521A;&#x521A;&quot;</span>
    }
    <span class="hljs-keyword">if</span> delta &lt; <span class="hljs-number">3600</span> {
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;<span class="hljs-subst">\(delta / <span class="hljs-number">60</span>)</span> &#x5206;&#x949F;&#x524D;&quot;</span>
    }
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;<span class="hljs-subst">\(delta / <span class="hljs-number">3600</span>)</span> &#x5C0F;&#x65F6;&#x524D;&quot;</span>
}
</code></pre>
<h2 id="%E9%9B%86%E6%88%90%E6%97%A5%E6%9C%9F%E5%A4%84%E7%90%86">&#x96C6;&#x6210;&#x65E5;&#x671F;&#x5904;&#x7406;</h2>
<ul>
<li>&#x5C06;&#x5206;&#x7C7B;&#x62D6;&#x62FD;&#x81F3;&#x9879;&#x76EE;&#x7684; <code>Tools</code> &#x76EE;&#x5F55;</li>
<li>&#x5728; <code>StatusViewModel</code> &#x4E2D;&#x589E;&#x52A0;&#x8BA1;&#x7B97;&#x578B;&#x5C5E;&#x6027;</li>
</ul>
<pre><code class="lang-swift"><span class="hljs-comment">/// &#x5FAE;&#x535A;&#x521B;&#x5EFA;&#x65F6;&#x95F4;</span>
<span class="hljs-keyword">var</span> createAt: <span class="hljs-type">String</span>? {
    <span class="hljs-keyword">return</span> <span class="hljs-type">NSDate</span>.sinaDate(status.created_at ?? <span class="hljs-string">&quot;&quot;</span>)?.dateDesription
}
</code></pre>
<ul>
<li>&#x5728; <code>StatusCellTopView</code> &#x4E2D;&#x8BBE;&#x7F6E;&#x663E;&#x793A;&#x65E5;&#x671F;</li>
</ul>
<pre><code class="lang-swift">timeLabel.text = statusViewModel?.createAt
</code></pre>
<blockquote>
<p>&#x8FD0;&#x884C;&#x6D4B;&#x8BD5;:D</p>
</blockquote>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../ending/index.html" class="navigation navigation-prev " aria-label="Previous page: 微博收尾"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../ending/regex.html" class="navigation navigation-next " aria-label="Next page: 正则表达式"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

<script>
require(["gitbook"], function(gitbook) {
    var config = {"fontSettings":{"theme":null,"family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
